package com.gree.flowable.app.controller;

import com.gree.flowable.app.pojo.to.FormDataExTO;
import com.gree.flowable.app.pojo.vo.ReturnVO;
import com.gree.flowable.app.services.IFormDataExService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author ：180849
 * @date ：Created in 2021/4/21 16:12
 * @description：
 * @modified By：
 * @version: 1.0
 */
@RestController

@Api(tags = "表单数据扩展表API")
@RequestMapping("/rest/formDataExApi")
public class IFormDataExApi {
    @Autowired
    private IFormDataExService formDataExService;

    @PostMapping("/formDataEx")
    @ApiOperation("添加扩展表数据")
    @ApiImplicitParam(name = "formDataExTO",value = "扩展表数据",dataType = "FormDataExTO")
    public ReturnVO addFormDateEx(@RequestBody FormDataExTO formDataExTO){
        Map<String, Object> data = formDataExTO.getData();
        String prid = formDataExTO.getPrid();
        String formId = formDataExTO.getFormId();
        return formDataExService.addFormDataEx(prid,formId,data);
    }

    @PutMapping("/formExData")
    @ApiOperation("修改扩展表数据")
    @ApiImplicitParam(name = "formDataExTO",value = "扩展表数据",dataType = "FormDataExTO")
    public ReturnVO updateFormDateEx(@RequestBody FormDataExTO formDataExTO){
        Map<String, Object> data = formDataExTO.getData();
        String prid = formDataExTO.getPrid();
        String formId = formDataExTO.getFormId();
        return formDataExService.addFormDataEx(prid,formId,data);
    }

    @GetMapping("/formDataEx/{prid}/{formId}")
    public ReturnVO getFormDataEx(@PathVariable String prid, @PathVariable String formId){
        return formDataExService.queryFormEx(prid, formId);
    }
}
